package com.juphoon.mockdata.data.dto;

import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.juphoon.mockdata.util.E06Utils;
import com.juphoon.mockdata.util.XmlHelper;
import lombok.Builder;
import lombok.Data;

import java.io.IOException;
import java.util.Random;

@Data
@Builder
public class E06CustomerRiskLevelListDTO implements BaseResponseDTO{
    //  <struct>
    //                <TODAY_RATING_TIMES attr="s,10,F">3</TODAY_RATING_TIMES>
    //                <VALIDATE_FLAG attr="s,10,F">1</VALIDATE_FLAG>
    //                <PAPER_TYPE attr="s,10,F">0</PAPER_TYPE>
    //                <CLIENT_NAME attr="s,150,F">雷一鸣</CLIENT_NAME>
    //                <ABATE_DATE attr="s,8,F">20240810</ABATE_DATE>
    //                <RATING_DATE attr="s,8,F">20230810</RATING_DATE>
    //                <SUB_BRANCH_ID attr="s,20,F">12001</SUB_BRANCH_ID>
    //                <RATING_TIMES attr="s,10,F">3</RATING_TIMES>
    //                <CHANNEL_FLAG attr="s,20,F">综合柜面系统</CHANNEL_FLAG>
    //                <RISK_TYPE attr="s,20,F">C4</RISK_TYPE>
    //                <ACCEPT_RISK_SCORE attr="d,20,2,F">56.00</ACCEPT_RISK_SCORE>
    //                <REGISTERED_TELLER_NO attr="s,30,F">12887</REGISTERED_TELLER_NO>
    //                <BUSS_TYPE attr="s,30,F">0</BUSS_TYPE>
    //                <SEQ_NO attr="s,52,F">10001520230810000000532992</SEQ_NO>
    //                <RISK_ASSESS_SOURCE attr="s,10,F">1</RISK_ASSESS_SOURCE>
    //                <RISK_LEVEL attr="s,6,F">R4</RISK_LEVEL>
    //            </struct>
    @JacksonXmlProperty(localName = "TODAY_RATING_TIMES")
    private String TODAY_RATING_TIMES;
    @JacksonXmlProperty(localName = "VALIDATE_FLAG")
    private String VALIDATE_FLAG;
    @JacksonXmlProperty(localName = "PAPER_TYPE")
    private String PAPER_TYPE;
    @JacksonXmlProperty(localName = "CLIENT_NAME")
    private String CLIENT_NAME;
    @JacksonXmlProperty(localName = "ABATE_DATE")
    private String ABATE_DATE;
    @JacksonXmlProperty(localName = "RATING_DATE")
    private String RATING_DATE;
    @JacksonXmlProperty(localName = "SUB_BRANCH_ID")
    private String SUB_BRANCH_ID;
    @JacksonXmlProperty(localName = "RATING_TIMES")
    private String RATING_TIMES;
    @JacksonXmlProperty(localName = "CHANNEL_FLAG")
    private String CHANNEL_FLAG;
    @JacksonXmlProperty(localName = "RISK_TYPE")
    private String RISK_TYPE;
    @JacksonXmlProperty(localName = "ACCEPT_RISK_SCORE")
    private String ACCEPT_RISK_SCORE;
    @JacksonXmlProperty(localName = "REGISTERED_TELLER_NO")
    private String REGISTERED_TELLER_NO;
    @JacksonXmlProperty(localName = "BUSS_TYPE")
    private String BUSS_TYPE;
    @JacksonXmlProperty(localName = "SEQ_NO")
    private String SEQ_NO;
    @JacksonXmlProperty(localName = "RISK_ASSESS_SOURCE")
    private String RISK_ASSESS_SOURCE;
    @JacksonXmlProperty(localName = "RISK_LEVEL")
    private String RISK_LEVEL;

    public String wrapRiskStyle(String risk_type) {
        if (StrUtil.equals(risk_type, "C1")) {
            return "保守型";
        } else if (StrUtil.equals(risk_type, "C2")) {
            return "稳健型";
        } else if (StrUtil.equals(risk_type, "C3")) {
            return "平衡型";
        } else if (StrUtil.equals(risk_type, "C4")) {
            return "进取型";
        } else if (StrUtil.equals(risk_type, "C5")) {
            return "飞跃型";
        }
        return "";
    }

    @Override
    public String genData() {
        E06CustomerRiskLevelListDTO e06CustomerRiskLevelListDTO = E06CustomerRiskLevelListDTO.builder()
                .RISK_LEVEL(GetRandomData("1","2","3"))
                .build();
                ;

        e06CustomerRiskLevelListDTO.setRISK_LEVEL(GetRandomData("1","2","3"));
        e06CustomerRiskLevelListDTO.setACCEPT_RISK_SCORE(GetRandomData("1","2","3"));
        e06CustomerRiskLevelListDTO.setRISK_TYPE(GetRandomData("0"));
        e06CustomerRiskLevelListDTO.setCLIENT_NAME(GetRandomData("123456","33333","232323"));
        e06CustomerRiskLevelListDTO.setCHANNEL_FLAG(GetRandomData("name1","name2","name3"));
        e06CustomerRiskLevelListDTO.setRISK_LEVEL(GetRandomData("l1","l2","l3"));
        e06CustomerRiskLevelListDTO.setPAPER_TYPE(GetRandomData("t1","t2","t3"));
        try {
            return E06Utils.wrapXmlString(new XmlHelper().toXml(e06CustomerRiskLevelListDTO));
        } catch (IOException e) {
            throw new RuntimeException(e);

        }
    }

    private static String GetRandomData(String... strings){
        int len = strings.length;
        Random random = new Random();
        int index = random.nextInt(len);
        return strings[index];
    }

}
